// Problem: P1012 [NOIP1998 提高组] 拼数
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1012#submit
// Memory Limit: 128 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int N =1e9+7;

int n;
int main()
{
    cin>>n;
    vector<string> v;
    for(int i=0;i<n;++i)
    {
    	string s;cin>>s;
    	v.push_back(s);
    }
    sort(v.begin(),v.end(),[](const string& a,const string& b) -> bool
    {
    	return a+b>b+a;
    });
    
    for(int i=0;i<n;++i)
    	cout<<v[i];
    return 0;
}